
#! /bin/bash

CURRENT_PWD=$(cd "$(dirname "$0")";pwd)

CURRENT_ARCH=$(dpkg --print-architecture)

# aclocal: not found
sudo apt-get install automake -y
# libevent not found
sudo apt-get install libevent-dev -y
# yacc not found
sudo apt-get install bison -y

cd ..

chmod +x autogen.sh

./autogen.sh

./configure --prefix=$CURRENT_PWD/debian/opt/apps/github.tmux.tmux/files --enable-static

make -j8

# make install

sed -i "/^Architecture:/cArchitecture: ${CURRENT_ARCH}" $CURRENT_PWD/debian/DEBIAN/control

cd $CURRENT_PWD

mkdir -p $CURRENT_PWD/debian/opt/apps/github.tmux.tmux/files/bin

cp ../tmux $CURRENT_PWD/debian/opt/apps/github.tmux.tmux/files/bin

# Depends: libc6 (>= 2.27), libevent-2.1-7 (>= 2.1.8-stable), libtinfo6 (>= 6)
# dpkg-shlibdeps -O ../tmux > shlibs.txt

#dpkg -b debian "github.tmux.tmux_3.1c_${CURRENT_ARCH}.deb"

# uos root-owner-group
dpkg-deb --root-owner-group  -b debian "github.tmux.tmux_3.1c_${CURRENT_ARCH}.deb"
